package com.wyl.mybatis.factory;

import cn.hutool.json.JSONUtil;
import org.apache.ibatis.reflection.factory.DefaultObjectFactory;
import org.apache.ibatis.reflection.factory.ObjectFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.Serializable;
import java.util.List;
import java.util.Properties;

/**
 * @Description
 * @Author WuYiLong
 * @Date 2024/3/14 13:57
 */
public class CustomObjectFactory extends DefaultObjectFactory {

    private final static Logger log = LoggerFactory.getLogger(CustomObjectFactory.class);
    public CustomObjectFactory() {
        super();
    }

    @Override
    public <T> T create(Class<T> type, List<Class<?>> constructorArgTypes, List<Object> constructorArgs) {
        T t = super.create(type, constructorArgTypes, constructorArgs);
        log.info("初始化的对象：{}",t.getClass().getSimpleName());
        return t;
    }

    @Override
    public void setProperties(Properties properties) {
        String id = properties.getProperty("id");
        String name = properties.getProperty("name");
        log.info("初始化参数: id={},name={}",id,name);
    }
}
